package com.bigShen.pattern.delegate.leader;

import com.bigShen.pattern.delegate.leader.worker.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: lei.shen
 * @date: 2018/10/6
 */
public class Leader {

    private static Map<String, Worker> handlerMapping = new HashMap<String, Worker>();

    static {
        handlerMapping.put("产品", new WorkerProduct());
        handlerMapping.put("资产", new WorkerAsset());
        handlerMapping.put("交易", new WorkerTrade());
        handlerMapping.put("风控", new WorkerRisk());
    }

    public void doDispatcher(String command) {

        Worker worker = handlerMapping.get(command);
        if (null != worker) {
            worker.working(command);
        } else {
            throw new RuntimeException("暂不支持的处理任务!");
        }

    }

}
